<?php

class TintucController extends Henry_Controller_Action
{
    public function init()
    {
        parent::init();
        $this->_helper->layout->setLayout('other');
    }
    public function detailAction(){
        $id = $this->_request->getParam("id",-1);        
        $serviceOb = new Henry_News_News();
        if ($id != -1){
            $tmp = $serviceOb->find($id)->toArray();
            $this->view->item = $tmp[0];
        }
    }

    public function indexAction(){
        $serviceOb = new Henry_News_News();

//        $id = $this->_request->getParam("id",-1);
//        if ($id != -1){
//            $tmp = $serviceOb->find($id)->toArray();
//        }else{
//            $tmp = $serviceOb->fetchAll(null,"create_date desc",1,$this->_getParam("page"))->toArray();
//        }
//        $this->view->clipItem = $tmp[0];

    	$paginator = Zend_Paginator::factory($serviceOb->selectPhantrang());
    	$paginator->setCurrentPageNumber($this->_getParam("page")); // Note: For this to work of course, your URL must be something like this: http://localhost:8888/index/index/page/1 <- meaning we are currently on page one, and pass that value into the "setCurrentPageNumber"
	$paginator->setItemCountPerPage(8);
	$paginator->setPageRange(10);
        $this->view->paginator = $paginator;
        $page = $this->_request->getParam("page", -1);
        if ($page == -1){
            $this->view->currentPage = "";
        }else{
            $this->view->currentPage = "/page/".$page;
        }
    }

}

